home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac-Source 1994 July
/
Mac-Source_July_1994.iso
/
C and C++
/
Libraries
/
MacTCP class library
/
MacTCP class headers
/
CMacTCPDriver.h
< prev
next >
Wrap
Text File
|
1992-10-26
|
6KB
|
164 lines
/*
CMacTCPDriver.h
Superclass: CObject
The MacTCP Driver implementation (Chapter 2, MacTCP Programmer's Guide).
Copyright © NCSA, University of Illinois; June 2, 1992
Eric Johnson, John Newlin and Igor Livshits
This code may be used, modified, and distributed free of charge and obligation.
*/
#define _H_CMacTCPDriver // Include this file only once
#include <Devices.h>
#define kDriverName "\p.IPP" // MacTCP registers itself under this name
#define kInProgress 1 // I/O in progress
#define kUserCanceled -1 // User canceled current action
#define kSynchronous False // For synchronous calls
#define kAsynchronous True // For asynchronous calls
#define kTimeOut 60 // One minute
#define kDriverError 2622 // Messages to the user
#define kCantOpen 1 // Cannot open the MacTCP driver
// MacTCP result codes (-23000 through -23049)
#define kIPBadLapErr -23000 // Bad network configuration
#define kIPBadCnfgErr -23001 // Bad IP configuration error
#define kIPNoCnfgErr -23002 // Missing IP or LAP configuration error
#define kIPLoadErr -23003 // Error in MacTCP load
#define kIPBadAddr -23004 // Error in getting address
#define kConnectionClosing -23005 // Connection is closing
#define kInvalidLength -23006 // Invalid specified length
#define kConnectionExists -23007 // Request conflicts with existing connection
#define kConnectionDoesntExist -23008 // Connection does not exist
#define kInsufficientResources -23009 // Insufficient resources to perform request
#define kInvalidStreamPtr -23010 // Invalid stream pointer
#define kStreamAlreadyOpen -23011 // This stream is already open
#define kConnectionTerminated -23012 // Connection terminated
#define kInvalidBufPtr -23013 // Invalid buffer pointer
#define kInvalidRDS -23014 // Invalid read
#define kInvalidWDS -23014 // Invalid write
#define kOpenFailed -23015 // Open action failed
#define kCommandTimeout -23016 // Action took too long
#define kDuplicateSocket -23017 // Duplicate socket
// Error codes from internal IP functions
#define kIPDontFragErr -23032 // Packet too large to send w/o fragmenting
#define kIPDestDeadErr -23033 // Destination not responding
#define kIPNoFragMemErr -23036 // No memory to send fragmented pkt
#define kIPRouteErr -23037 // Can't route packet off-net
// General errors
#define kNameSyntaxErr -23041 // Error in name specification
#define kCacheFault -23042 // Cache fault
#define kNoResultProc -23043 // Result routine not specified
#define kNoNameServer -23044 // No name server avaialable
#define kAuthNameErr -23045 //
#define kNoAnsErr -23046 // No answer
#define kDNRErr -23047 // Dynamic Name Resolver error
#define kOutOfMemory -23048 // Out of memory
enum
{ // Command codes
UDPCreate= 20,
UDPRead,
UDPBfrReturn,
UDPWrite,
UDPRelease,
UDPMaxMTUSize,
TCPCreate= 30,
TCPPassiveOpen,
TCPActiveOpen,
TCPSend= 34,
TCPNoCopyRcv,
TCPBfrReturn,
TCPRcv,
TCPClose,
TCPAbort,
TCPStatus,
TCPRelease= 42,
TCPGlobalInfo
};
typedef unsigned short tcp_port; // TCP port (UNICOS 6 only likes the lower 15 bits)
typedef unsigned char byte; // 8 bits
typedef unsigned char b_8; // An 8-bit quantity
typedef unsigned short b_16; // A 6-bit quantity
typedef unsigned long b_32; // A 32-bit quantity
typedef b_32 ip_addr; // IP addresses are 32-bits
typedef b_16 ip_port; // Port number / reference
typedef OSErr (*OSErrProcPtr) // A function that returns an operating system error
();
typedef Ptr (*PtrProcPtr) // A function that returns a pointer to something
();
typedef Boolean (*BooleanProcPtr) // A function that returns a true or false value
();
typedef void (*voidProcPtr) // A pascal type procedure that returns nothing
();
/*===---------------===*/
class CMacTCPDriver : public CObject
Begin
protected:
ParmBlkPtr parameterBlock; // The parameter block for control routines
Size sizeOfParameters; // Size of our parameter block
OSErr itsLastError; // Last error we encountered
short refNum; // Reference for our driver
Boolean fAsynchronous; // Synchrounous or asynchronous
public:
OSErr IMacTCPDriver // Initialize the driver
( void // No arguments
);
void Dispose // Destroy the driver object
( void // No arguments
);
virtual void SendControlInfoToDriver // Send control information to the driver
( void // No arguments
);
virtual void Process // Process current action (set by Control() )
( void // No arguments
);
virtual Boolean Done // Is anything still in the queue?
( void // No arguments
);
virtual void GetParameters // Gets the current parameters
( ParmBlkPtr* duplicateParameters // A clone is copied here
);
virtual void SetParameters // Sets the current parameters
( ParmBlkPtr newParameters // New parameters to set
);
virtual void SetMode // Sets control mode
( Boolean mode // Mode flag
);
virtual Boolean GetMode // Gets control mode
( void // No arguments
);
protected:
virtual void MakeParameters // Create the parameter block
( void // No arguments
);
virtual void SetCompletionProc // Sets the completion routine
( ProcPtr myRoutine // What to call while waiting
);
// *** Subclass must over-ride! *** //
virtual void Wait // Waits...
( void // No arguments
);
virtual void SetSizeOfParameters // Sets the size of the parameter block
( void // No arguments
);
End;
/*===---------------===*/
/*=====================*/